package com.zjy.utils;

import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Map;

/**
 * @auther ljh
 * @creatat 2018/8/7
 */
public class ObjectUtils {


    public static boolean isNullOrEmpty(Object obj) {
        if (obj == null) {
            return true;
        } else if (obj instanceof String) {
            return ((String) obj).trim().equals("");
        } else if (obj instanceof Collection<?>) {
            return ((Collection<?>) obj).isEmpty();
        } else if (obj instanceof Map<?, ?>) {
            return ((Map<?, ?>) obj).isEmpty();
        } else {
            return obj.getClass().isArray() && Array.getLength(obj) == 0;
        }
    }


}
